package hit.example.adapter;

import hit.example.Object.ObjVietAnh;
import hit.example.Object.ObjWord;
import hit.example.hitdict.R;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class AdapterSearchVietAnh extends ArrayAdapter<ObjVietAnh> {

	Activity context;
	int LayoutID;
	ArrayList<ObjVietAnh> list;

	public AdapterSearchVietAnh(Activity context2, int layoutID, ArrayList<ObjVietAnh> list) {
		super(context2, layoutID,list);
		context = context2;
		LayoutID = layoutID;
		this.list = list;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		convertView = context.getLayoutInflater().inflate(LayoutID, null);
		TextView txtEng = (TextView) convertView.findViewById(R.id.txtEnglish);
		TextView txtViet = (TextView) convertView.findViewById(R.id.txtViet);
		txtEng.setText(list.get(position).getEn());
		txtViet.setText(list.get(position).getVi());
	
		return convertView;
	}

	public void setItems(ArrayList<ObjVietAnh> items) {
		clear();

		if (items != null)
			for (ObjVietAnh obj : items) {
				//add(obj);
			}

	}
}
